﻿import java.util.Scanner;
import javax.swing.JOptionPane;
/**
 * Created by mengwei666 on 2016/9/22.
 */
public class exercise_1 {


        public static void main(String[] args) {
            // out练习
            System.out.print("Hello");
            System.out.print(33);
            System.out.print("\t");
            System.out.println("Hello World");
            System.out.printf("%d ; %d%n",33,2324L);
            System.out.printf("%.3f ; %8.4f%n",2.33,1.2345);


            //Scanner练习
            Scanner reader = new Scanner(System.in);
            System.out.println("请输入一个整数:");
            int x = reader.nextInt();
            System.out.print("它的相反数为:");
            System.out.println(-x);

            System.out.println("连续输入浮点数，输入0将结束输入");
            while(reader.hasNext()){
                double m = reader.nextDouble();
                if(m==0){
                    break;
                }
            }
            System.out.println("完成浮点数输入");
            reader.next();      //输入字符串
            // reader.close();         //内层System.in关闭
            reader.next();          //验证是否还能工作

            // GUI练习
            JOptionPane.showMessageDialog(null,"Welcome to Java");

            String log = JOptionPane.showInputDialog("What's your name?");
            String message = String.format("Welcome,%s, to Java Programming,",log);
            JOptionPane.showMessageDialog(null,message);
        }
}

